package ${package.Controller};


import org.springframework.web.bind.annotation.*;

<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
import ${package.Service}.${table.serviceName};
import org.springframework.beans.factory.annotation.Autowired;
import ${package.Entity}.${entity};
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import tianrun.ziguan.api.common.core.base.ResultBody;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;


/**
* <p>
* ${table.comment!} Controller控制器
* </p>
*
* @author ${author}
* @since ${date}
*/
@Api(tags = "${table.comment!} 控制器")
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
    <#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
    <#else>
public class ${table.controllerName} {
    </#if>

    @Autowired
    private ${table.serviceName} ${table.serviceName?substring(1)?uncap_first};


    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @ApiOperation(value = "分页查询列表", response = ${entity}.class)
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pageIndex", value = "页面", dataType = "Long"),
        @ApiImplicitParam(name = "pageSize", value = "页面数据量", dataType = "Long")
    })
    @PostMapping(value = "/pageList")
    public ResultBody<IPage<${entity}>> pageList(@Validated @RequestBody ${entity} param) {
        return ResultBody.of(${table.serviceName?substring(1)?uncap_first}.pageList(param));
    }

    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @ApiOperation(value = "查询列表", response = ${entity}.class)
    @PostMapping(value = "/queryList")
    public ResultBody<List<${entity}>> queryList(@Validated @RequestBody ${entity} param) {
        return ResultBody.of(${table.serviceName?substring(1)?uncap_first}.queryList(param));
    }

    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @ApiOperation(value = "获取详情", response = ${entity}.class)
    @GetMapping(value = "/info/{id}")
    public ResultBody<${entity}> info(@PathVariable Long id) {
        ${entity} data = ${table.serviceName?substring(1)?uncap_first}.info(id);
        return ResultBody.of(data);
    }

    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @ApiOperation(value = "新增")
    @PostMapping(value = "/add")
    public ResultBody<Boolean> add(@Validated @RequestBody ${entity} param) {
        return ResultBody.of(${table.serviceName?substring(1)?uncap_first}.add(param));
    }

    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @ApiOperation(value = "修改")
    @PostMapping(value = "/edit")
    public ResultBody<Boolean> edit(@Validated @RequestBody ${entity} param) {
        return ResultBody.of(${table.serviceName?substring(1)?uncap_first}.edit(param));
    }

    @ApiOperation(value = "批量删除多个数据")
    @PostMapping(value = "/batchDelete")
    public ResultBody<Boolean> batchDelete(@Validated @RequestBody List<Long> ids) {
        return ResultBody.of(${table.serviceName?substring(1)?uncap_first}.batchDelete(ids));
    }

}
</#if>
